//
//  KLSdk.h
//  WebRTCDemo_iOS
//
//  Created by szblsx2 on 2020/3/5.
//  Copyright © 2020 szblsx2. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "KLMeetUser.h"


NS_ASSUME_NONNULL_BEGIN

@protocol kularkDelegate <NSObject>

@optional
/**
*  获取到房间用户列表回调
*  @param userList 用户列表
*/
- (void)respRoomUserList:(NSArray<KLMeetUser *> *)userList;

/**
*  新用户进入房间回调
*  @param newUser 用户信息
*/
- (void)respUserJoinRoom:(KLMeetUser *)newUser;

/**
*  房间用户离开回调
*  @param userId 用户id
*/
- (void)respUserLeaveWithUserId:(NSString *)userId;

/**
 *  本地媒体回调
 *  @param captureSession 媒体session
 */
- (void)addLocalCapturerSession:(AVCaptureSession *)captureSession;

/**
 * 远端添加媒体回调
 * @param mediaStream 媒体信息
 * @param streamId 流id
 * @param userId 用户id
 */
- (void)addRemoteMediaStream:(RTCMediaStream *)mediaStream streamId:(NSString *)streamId userId:(NSString *)userId;

/**
 *  远端移除媒体回调
 *  @param streamId 流id
 *  @param userId 用户id
 */
- (void)removeRemoteMediaStreamWithStreamId:(NSString *)streamId userId:(NSString *)userId;

/**
 *  会议广播回调
 *  @param type 广播类型
 *  @param targetUserId 目标用户id
 *  @param state 状态
 */
- (void)resMeetingNotificationWithType:(KLNotifiType)type targetUserId:(NSString *)targetUserId state:(BOOL)state;

@end

@interface KLSdk : NSObject

@property (nonatomic, weak) id<kularkDelegate> delegate;

- (instancetype)init NS_UNAVAILABLE;
+ (instancetype)new NS_UNAVAILABLE;

+ (instancetype)shared;

/**
*  初始化SDK
*  @param server 信令服务器地址
*  @param port     端口号
*/
- (void)initSDKWithServer:(NSString *)server port:(NSString *)port;

/**
*  设置turn转发服务器地址 如不设置则为默认地址
*  @param iceServers  服务器地址
*/
- (void)setupIceServers:(NSArray<RTCIceServer *> *)iceServers;

/**
*  进入会议(创建、加入)
*  @param roomId 会议号
*  @param myInfo 入会信息及配置
*  @param completion 回调
*/
- (void)enterMeetingWithRoomId:(NSString *)roomId
                       myInfo:(KLMeetUser *)myInfo
                     completion:(void(^)(BOOL result))completion;

/**
*  离开会议
*/
- (void)leaveMeeting;

/**
*  根据用户id选择订阅流 （仅视频会议有效）
*  @param userIds 需要订阅流的用户Id集合
*/
- (void)chooseMediaSoucesWithUserIds:(NSArray *)userIds;

/**
*  是否打开摄像头 默认开启
*  @param open 是否开启
*/
- (void)turnOnCamera:(BOOL)open;

/**
*  切换前后置摄像头 默认前置
*/
- (void)switchCamera;

/**
*  是否打开麦克风 默认开启
*  @param open 是否开启
*/
- (void)turnOnMicrophone:(BOOL)open;

/**
*  是否开启扬声器
*  @param open 默认开启
*/
- (void)whetherToOpenLoudspeaker:(BOOL)open;

/**
*  发送自定义视频数据
*  @param sampleBuffer   视频帧数据
*/
- (void)sendVideoSampleBuffer:(CMSampleBufferRef)sampleBuffer;

/**
*  会议广播
*  @param notifiType 广播类型
*  @param targetUserId 目标Id  type为KLNotifiTypeMeetingMute时不传
*  @param state 状态 仅在 KLNotifiTypeMeetingMute、 KLNotifiTypeUserMute 生效
*/
- (void)sendMeetingNotificationWithType:(KLNotifiType)notifiType targetUserId:(NSString *)targetUserId state:(BOOL)state;

@end

NS_ASSUME_NONNULL_END
